/*
Table 1: Baseline (2009) means of outcomes and key characteristics by treatment assignment (transfer amounts in this table are naturally in constant, 2009 TSH as it was a 2009 survey)
*/

version 14.0
set more off


// Create local macros

loc household_characteristics	=	"improvedroof 		improvedfloor 			improvedtoilet 			pipedwater 				sex_head	"
loc trust_and_community			=	"dm_trust_leaders	dm_trust_most			dm_trust_comm			dm_contrib_CDP_labor	CLID2_parent_assn 	CLID2_vil_hlth_com 	"

loc received_from_individuals	=	"dm_cash_from_ind 	dm_food_from_ind 		dm_inkind_from_ind "
loc received_from_NGOS			=	"dm_cash_from_ngo 	dm_food_from_ngo 		dm_inkind_from_ngo"
loc received_from_govt			=	"dm_cash_from_gvt 	dm_food_from_gvt		dm_inkind_from_gvt"

loc transfers_received 			= 	"trans_from_tot	trans_from_ind			trans_from_gvt			trans_from_ngo	"
loc transfers_given				= 	"value_gift_tot	value_gift_cash		value_gift_food		value_gift_inkind "



#delimit ;
	loc all_lists = "
	household_characteristics
	trust_and_community

	received_from_individuals
	received_from_NGOS
	received_from_govt

	transfers_received
	transfers_given"		;
#delimit cr



//	summarize the variables
loc i = 0
foreach gp in 	`all_lists'		{	
	di "`gp'"
	foreach v in ``gp'' {
		di "  `v'"
		if inlist("`v'", "CLID2_parent_assn", "CLID2_vil_hlth_com")	use   "village_level_final", clear
		else														use "household_level_final", clear

		keep if period == 1
		
		cap foreach x in trans_from_tot 	    trans_from_ind	    	trans_from_gvt			trans_from_ngo		value_gift_tot		value_gift_cash 		value_gift_food		value_gift_inkind {
		loc labl: var label `x'
		replace `x'=(`x'/1000)
		label var `x' "`labl' (1000s cons 2009 TSH)"
		}
		*Note, these are 2009 constant TSH since this is just baseline data and the data are FROM 2009 (only for midline and endline data do we need to muliply by a deflator to put them into 2009 TSH)
			
		loc ++i

		loc		`i'_lab: var label `v'
		loc		`i'_name			= "`v'"
		loc		`i'_gp				= "`gp'"

		ttest 	`v'	, by(treat_village)
		sum `v', det

		reg		`v'	treat_village	, cluster(CLID)
	
	}
}



exit

